//
//  HomePageDetailVideoItemCell.m
//  ShowYork
//
//  Created by hxh on 2020/10/8.
//  Copyright © 2020 hxh. All rights reserved.
//

#import "CampusVlogDetailCell.h"
#import "CampustDetailFooterView.h"
@interface CampusVlogDetailCell ()<CampustDetailFooterViewDelegate>
@property (nonatomic,strong)UIImageView *coverImgView;
@property (nonatomic,strong)CampustDetailFooterView *footerView;

@end

@implementation CampusVlogDetailCell



- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self setUI];
    }
    return self;
}

- (void)setUI{
   
    self.backgroundColor = [UIColor blackColor];
   
    self.coverImgView = [[UIImageView alloc]init];
    self.coverImgView.tag = 100;
    self.coverImgView.contentMode = UIViewContentModeScaleAspectFit;
    [self.contentView addSubview:self.coverImgView];
   
    [self.coverImgView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.left.right.bottom.equalTo(self.contentView);
    }];
    
    __weak typeof(self)weakSelf = self;
    
    self.footerView = [[CampustDetailFooterView alloc]initWithCompleteBlock:^(kXHFooterType type) {
        if (type == kXHCampusFooterLike) {
            if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(videoItemLikeWithCurrentModel:)]) {
                [weakSelf.delegate videoItemLikeWithCurrentModel:weakSelf.model];
            }
        }
        if (type == kXHCampusFooterDiss) {
            if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(videoItemDissWithCurrentModel:)]) {
                [weakSelf.delegate videoItemDissWithCurrentModel:weakSelf.model];
            }
        }
        if (type == kXhCampusFooterShare) {
            if (weakSelf.delegate && [weakSelf.delegate respondsToSelector:@selector(videoItemShareWithCurrentModel:)]) {
                [weakSelf.delegate videoItemShareWithCurrentModel:weakSelf.model];
            }
        }
    }];
    [self.footerView showInView:self.contentView delegate:self];
}


- (void)setModel:(CampusSchoolVideoItemModel *)model{
    _model = model;
   

    [self.coverImgView sd_setImageWithURL:[NSURL URLWithString:model.cover]];

    [self.footerView setItemModel:model];
    
}

+(instancetype)cellWithTableView:(UITableView *)tableView{
    NSString *ID = @"CampusVlogDetailCell";
    CampusVlogDetailCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    if (!cell) {
        cell = [[CampusVlogDetailCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
    }
    return cell;
}

- (void)updateProgressValue:(CGFloat)value{
    self.footerView.progressValue = value;
}
    
- (void)updateVideoProgressValue:(CGFloat)value{
    if (self.delegate && [self.delegate respondsToSelector:@selector(videoItemUpdateProgressValue:)]) {
        [self.delegate videoItemUpdateProgressValue:value];
    }
}

- (void)progressBeginDraging{
    if (self.delegate && [self.delegate respondsToSelector:@selector(videoItemBeginDraging)]) {
        [self.delegate videoItemBeginDraging];
    }
}
- (void)changeVideoProgressValue:(CGFloat)value{
    if (self.delegate && [self.delegate respondsToSelector:@selector(videoItemChangeProgressValue:)]) {
        [self.delegate videoItemChangeProgressValue:value];
    }
}


@end
